import time 
from mylib import UartCommend, Camera ,ModelRunner


# 初始化串口通信
uartcommend = UartCommend(uart_port=1, baudrate=115200)

# 初始化摄像头
camera = Camera()

# 初始化模型
model = ModelRunner() 


while True:
    # 获取图像和FPS
    img_roi = camera.get_image()
    while(uartcommend.uart.any()):
        data = uartcommend.get_uart_data()
        if data:
            if data == '1':  # 如果数据是0x01，运行模型
                # 跑模型
                result = model.classify_image(img_roi)
                uartcommend.send_uart_data(result[0])
                uartcommend.send_uart_data(result[1])
                